<template>
<scroll-view class="index_list" :scroll-top='top' :style="height?'height:'+height +' !important':''" :lower-threshold='100' :scroll-y="true"  @scrolltolower='getMore'>
	<view class="">
	<view v-if="type_name!='city'&&total>0" class="top_ding" >
		<view class="">
			为您找到 <text style="color:red;font-size: 14px;">{{total>=10000?' 10000+ ':(' '+total+' ')}}</text> 
			<text v-if="type_name_a">{{type_name_a=='park1'?'个厂房':type_name_a=='park2'?'栋楼宇':'个地块'}}</text>
			<text v-else>{{type_name=='company'?'家企业':
				type_name=='park'?'个园区':
				type_name=='project'?'个项目':type_name=='hks'?'个会客室':'条政策'}}</text>
		</view>
		<view class="more_div" v-show="isMore" @click="toMore">
			查看更多
		</view>
	</view>
	<view v-if="type_name!='city'"  class="list_item flex_sb" v-for="(item,index) in list" :key="index" @click="toDetail(item)">
		<view class="img" :class="isSmall?'img_small':''" v-if="type_name!='policy'" >
			<image mode="scaleToFill" v-if="type_name!='company'" :src="item.thumb||item.imgs||item.logo" :lazy-load='true'></image>
			<image v-else-if="type_name=='company'&&item.logo&&!item.isErr" @error="item.isErr=true" :src="item.logo" mode="" :lazy-load='true'></image>
			<view v-if="type_name=='company' && (item.isErr||!item.logo)" class="logo_name">{{ (!item.logo||item.logo.indexOf('.')>-1)? item.company_name.substring(0,4) : item.logo}}</view>
			<view class="img_level" v-show="!type_name_a" v-if="type_name!='company'">{{item.level_name||item.city_name}}</view>
		</view>
		<view class="right_div" :class="[type_name=='policy'?'div100':'',isSmall?'right_div_small':'']">
			<view class="r_title" v-if="type_name=='hks'">{{item.name}}</view>
			<view class="r_title" v-if="type_name.indexOf('park')>-1">{{item.park_name}}</view>
			<view class="r_title" v-if="type_name=='company'">{{item.company_name}}</view>
			<view class="r_title" v-if="type_name=='project'">{{item.name}}</view>
			<view class="r_title" v-if="type_name=='policy'">{{item.policy_name}}</view>
			
			<view class="chain_view" v-if="type_name.indexOf('park')>-1&&item.chain_name.length>0" v-for="(chain,index) in item.chain_name.slice(0,2)" :key="index">{{chain}}</view>
			<view class="chain_view" v-if="type_name=='project'&&item.chain_names.length>0" v-for="(chain,index) in item.chain_names.split(',').slice(0,2)" :key="index">{{chain}}</view>
			<view class="chain_view" v-if="type_name=='company'&&item.chain_name.length>0" v-for="(chain,index) in item.chain_name.split(',').slice(0,2)" :key="index">{{chain}}</view>
			
			<view class="chain_view chain_view1" v-if="type_name=='policy'&&item.type_name.length>0" v-for="(type,index) in item.type_name.split(',')" :key="index">{{type}}</view>
			<view class="chain_view" v-if="type_name=='policy'&&item.chain_names.length>0" v-for="(type,index) in item.chain_names.split(',').slice(0,3)" :key="index">{{type}}</view>
			
			<view class="add_view" v-if="type_name!='policy'"><image src="https://wqq103910.oss-cn-hangzhou.aliyuncs.com/images/fuzhou/image/index/dizhi.png" mode=""></image> {{item.address||item.city_name||'-'}}</view>
			<view class="flex_sb"  v-if="type_name=='policy'">
				<view class="add_view">{{item.city_name.split(',').join('-')}}</view>
				<view class="add_view add_view60">
					<text>{{item.from}}</text>	
				</view>
			</view>
			<view class="flex_sb">
				<view class="add_view" v-if="type_name=='hks'">
					<image src="https://wqq103910.oss-cn-hangzhou.aliyuncs.com/images/fuzhou/image/index/time.png" mode=""></image> {{item.open_time}}
				</view>
				<view class="add_view color_red" v-if="type_name=='hks'">
					<image src="https://wqq103910.oss-cn-hangzhou.aliyuncs.com/images/fuzhou/image/index/zczj.png" mode=""></image> {{item.price==0?'免费':item.price}}
				</view>
				<view class="add_view color_red" v-if="type_name=='policy'">
					<view class="" v-if="item.subsidy">
						<image src="https://wqq103910.oss-cn-hangzhou.aliyuncs.com/images/fuzhou/image/index/butie.png" mode="" v-if="item.subsidy"></image> {{'有资金补贴' + ' ' +(item.subsidy||'')}}
					</view>
				</view>
				<view class="add_view" v-if="type_name=='policy'">
					<image src="https://wqq103910.oss-cn-hangzhou.aliyuncs.com/images/fuzhou/image/index/time.png" mode=""></image> {{item.create_time}}
				</view>
				<view class="add_view" v-if="type_name!='policy'&&type_name!='hks'">
					<image v-if="type_name!='company'" src="https://wqq103910.oss-cn-hangzhou.aliyuncs.com/images/fuzhou/image/index/dianhua.png" mode="" ></image>
					<image v-else src="https://wqq103910.oss-cn-hangzhou.aliyuncs.com/images/fuzhou/image/index/zczj.png" mode="" ></image>
					<text v-if="type_name.indexOf('park')>-1">{{item.phone||'-'}} </text> 
					<text v-if="type_name=='project'">{{item.mobile||'-'}} </text> 
					<text v-if="type_name=='company'">{{item.register_money||'-'}} </text> 
				</view>
				<view class="add_view" v-if="item.juli||item._geo_distance">
					<image src="https://wqq103910.oss-cn-hangzhou.aliyuncs.com/images/fuzhou/image/index/juli.png" mode=""></image> {{item.juli||item._geo_distance}}
				</view>
			</view>
		</view>
	</view>
	<view v-else class="city_div">
		<view class="city_item" v-for="(item,index) in list" :key="index" @click="toDetail(item)">
			<image :src="item.thumb_x" mode=""></image>
			<view class="">{{item.city_name}}</view>
		</view>
	</view>
	<slot></slot>
	</view>
</scroll-view>
</template>
<script setup>
const props = defineProps({
	type_name:{
		type:String,
	},
	type_name_a:{
		type:String,
	},
	list:{
		type:Array,
		default:[]
	},
	total:{
		type:Number,
		default:0
	},
	isSmall:{
		type:Boolean,
		default:false
	},
	isYzy:{
		type:Boolean,
		default:false
	},
	height:{
		type:String,
	},
	isMore:{
		type:Boolean,
		default:false
	}
})
var winH = uni.getStorageSync('windowH')
var navH = uni.getStorageSync('navH1')

const style = reactive({
	height:'100%'
})
onMounted(()=>{
	if(!props.height){
		style.height = (winH - 72 - navH)+'px'
	}
})
const emit = defineEmits(["getMore","toDetail","toMore"])
const top = ref(0)

watch( () => props.total , (newValue) => {
	top.value = top.value==0?-1:0
})

function getMore(){
	emit("getMore")
}
function toMore(){
	emit("toMore")
}
function toDetail(item){
	if(props.type_name_a){
		uni.navigateTo({
			url:`/pages/dkDetail/dkDetail?type=${props.type_name_a}&id=`+item.id
		})
	}else if(props.type_name == 'park'){
		if(props.isYzy){
			uni.navigateTo({
				url:'/pages/parkDetail/yzyDetail?id='+item.id
			})
		}else{
			uni.navigateTo({
				url:'/pages/parkDetail/parkDetail?id='+item.id
			})
		}
		
	}else if(props.type_name == 'project'){
		uni.navigateTo({
			url:'/pages/proDetail/proDetail?id='+item.id
		})
	}else if(props.type_name == 'policy'){
		uni.navigateTo({
			url:'/pages/policyDetail/policyDetail?id='+item.id
		})
	}else if(props.type_name == 'company'){
		uni.navigateTo({
			url:'/pages/companyDetail/companyDetail?identification='+item.identification
		})
	}else if(props.type_name == 'city'){
		uni.navigateTo({
			url:'/pages/cityDetail/cityDetail?id='+item.id
		})
	}else if(props.type_name == 'hks'){
		uni.navigateTo({
			url:'/pages/hksDetail/hksDetail?id='+item.id
		})
	}
}
</script>
<style lang="scss" scoped>
.index_list{
	height: calc(100% - 72px);
	position: relative;
	width: 100%;
}
.top_ding{
	position: sticky;
	top: 0;
	background-color: #fff;
	z-index: 10;
	
	font-size: 12px;
	padding:8px 10px 4px;
	display: flex;
	justify-content: space-between;
	.more_div{
		color: #0091FF;
	}
}
//#ifdef APP-PLUS
.index_list{
	height: v-bind('style.height') !important
}
//#endif
.list_item{
	width: calc(100% - 30px);
	// min-height: 100px;
	padding: 10px;
	border-radius: 8px;
	box-shadow: 0px 1px 10px 0px #0A477519;
	margin: 10px 5px 15px;
	position: relative;
	.img_small{
		height: 40px !important;
		width: 40px !important;
		border-radius: 4px !important;
		text-align: center;
		font-size: 14px !important;
	}
	.img{
		width: 120px;
		height: 90px;
		border-radius: 6px;
		overflow: hidden;
		position: relative;
		box-shadow: 0 0 5px 0 rgba(0, 0,0, 0.1);
		.logo_name{
			height: 100%;
			width: 100%;
			display: flex;
			align-items: center;
			justify-content: center;
			font-weight: bold;
			background: #0091FF;
			color: #fff;
		}
		image{
			width: 100%;
			height: 100%;
		}
		.img_level{
			position: absolute;
			top: 6px;
			left: 0px;
			padding: 2px 8px;
			border-radius: 4px;
			background: linear-gradient(135deg,#0091FF33,#0091FF);
			font-size: 12px;
			color: #fff;
		}
	}
	.right_div_small{
		width: calc(100% - 50px) !important
	}
	.right_div{
		width: calc(100% - 130px);
		.r_title{
			font-size: 16px;
			color: #333;
		}
	}
	.chain_view{
		background-color: #ECF3FF;
		color: #3D7CE2;
		padding: 0 4px;
		height: 16px;
		line-height: 16px;
		border-radius: 2px;
		font-size: 12px;
		margin: 8px 5px 0 0;
		display: inline-block;
	}
	.chain_view1{
		color: #f93;
		background-color: #ff993333;
	}
	.add_view{
		display: flex;
		font-size: 12px;
		margin-top: 6px;
		color:#999;
		image{
			max-width: 14px;
			min-width: 14px;
			height: 14px;
			margin-right: 6px;
			margin-top: 1px;
		}
	}
	.add_view60{
		width: 60%;
		text{
			width: 100%;
			text-align: right;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
		}
	}
	.color_red{
		color: #f1340e;
	}
	.div100{
		width: 100%;
	}
}
.city_div{
	width: calc(100% - 10px);
	border-radius: 8px;
	position: relative;
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	.city_item{
		width: calc(50% - 5px);
		margin: 10px 0px;
		// box-shadow: 0px 1px 10px 0px #0A477519;
		image{
			width: 100%;
			height: 100px;
			border-radius: 6px;
		}
	}
}
</style>